package com.book.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.book.dto.BookQueryRequest;
import com.book.entity.Book;
import com.book.mapper.BookMapper;
import com.book.service.BookService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class BookServiceImpl extends ServiceImpl<BookMapper, Book> implements BookService {
    
    @Override
    public IPage<Book> getBookPage(BookQueryRequest request) {
        Page<Book> page = new Page<>(request.getPageNum(), request.getPageSize());
        return baseMapper.selectBookPage(page, request.getBookName(), request.getCategory(), request.getAuthor());
    }
    
    @Override
    public List<Map<String, Object>> getCategoryStatistics() {
        return baseMapper.getCategoryStatistics();
    }
    
    @Override
    public List<Map<String, Object>> getPriceRangeStatistics() {
        return baseMapper.getPriceRangeStatistics();
    }
} 